package game.module.mail.logic;

import game.HallServer;
import game.module.mail.bean.HallMailBean;
import game.module.mail.dao.MailDao;

/**
 * @author: Pomelo.Lee
 * @date: 2017年8月24日 下午7:30:12
 */
public class MailDaoHelper {

	static class SingletonHolder {
		static MailDaoHelper instance = new MailDaoHelper();
	}

	public static MailDaoHelper getInstance() {
		return SingletonHolder.instance;
	}

	public void asyncInsertMail(final HallMailBean mailBean) {
		HallServer.executorService.execute(new Runnable() {
			@Override
			public void run() {
				MailDao.getInstance().addUserMail(mailBean);
			}
		});
	}

	public void asyncUpdateMailState(final long id, final int isRead, final boolean isGainTime) {
		HallServer.executorService.execute(new Runnable() {
			@Override
			public void run() {
				MailDao.getInstance().updateMailState(id, isRead, isGainTime);
			}
		});
	}

	public static void asyncRemoveMail(final long id) {
		HallServer.executorService.execute(new Runnable() {
			@Override
			public void run() {
				MailDao.getInstance().removeMail(id);
			}
		});
	}

}
